<!--
  -- Copyright 2015 The Chromium Authors. All rights reserved.
  -- Use of this source code is governed by a BSD-style license that can be
  -- found in the LICENSE file.
  -->

<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-ripple/paper-ripple.html">

<dom-module id="track-list">
  <template>
    <style>
      :host {
        align-items: center;
        background: rgb(245, 245, 245);
        color: rgb(51, 51, 51);
        cursor: default;
        display: flex;
        flex-direction: column;
        font-size: 10pt;
        justify-content: flex-start;
        overflow-x: hidden;
        overflow-y: auto;
      }

      /* Track item. */
      .track {
        align-items: center;
        display: flex;
        flex: 0 0 auto;
        flex-direction: row;
        height: 48px;
        justify-content: flex-start;
        position: relative;
        width: 100%;
      }

      :host([expanded]) > .track:hover {
        background-color: rgba(0, 0, 0, 0.08);
      }

      /* Track icon. */
      .track .icon {
        background-position: center;
        background-repeat: no-repeat;
        flex: none;
        height: 32px;
        margin: 8px;
        pointer-events: none;
        width: 32px;
      }

      .track:hover .icon {
        background-image: -webkit-image-set(
            url(../assets/100/playlist_play.png) 1x,
            url(../assets/200/playlist_play.png) 2x);
        pointer-events: auto;
      }

      .track[active] .icon {
        background-image: -webkit-image-set(
            url(../assets/100/playlist_now_playing.png) 1x,
            url(../assets/200/playlist_now_playing.png) 2x);
      }

      /* Track data. */

      .track .data {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        justify-content: center;
        margin-left: 0;
        margin-right: 4px;
        min-width: 0;
      }

      .track .data .data-title,
      .track .data .data-artist {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .track .data .data-title {
        color: rgb(51, 51, 51);
        font-size: 13px;
        font-weight: 500;
      }

      .track .data .data-artist {
        color: rgb(100, 100, 100);
        font-size: 12px;
      }

      paper-ripple {
        bottom: 0;
        color: rgb(51, 51, 51);
        left: 0;
        position: absolute;
        right: 0;
        top: 0;
      }
    </style>
    <template is="dom-repeat" id="tracks" items="[[tracks]]">
      <div class="track" active$="[[item.active]]" index$="[[index]]" on-click="trackClicked">
        <div class="icon"></div>
        <div class="data">
          <div class="data-title">[[item.title]]</div>
          <div class="data-artist">[[item.artist]]</div>
        </div>
        <paper-ripple initial-opacity="0.08"></paper-ripple>
      </div>
    </template>
  </template>
  <script src="track_list.js"></script>
</dom-module>
